
#include "GameObject.h"
#include "../ScriptApi.h"

namespace GTA
{

#pragma region constructor
	GameObject::GameObject()
	{
		
	}

	GameObject::GameObject(u32 handle)
	{
		Handle = handle;
	}
	
	GameObject::GameObject(Scripting::Object obj)
	{
		Base = obj;
	}
#pragma endregion

#pragma region base
	u32 GameObject::Handle::get()
	{
		return _Handle;
	}
	void GameObject::Handle::set(u32 handle)
	{
		_Handle = handle;
	}

	Scripting::Object GameObject::Base::get()
	{
		Scripting::Object o;
		o.Handle = _Handle;
		return o;
	}
	void GameObject::Base::set(Scripting::Object obj)
	{
		Handle = obj.Handle;
	}

	bool GameObject::Exists()
	{
		if (Handle == 0) return false;
		return Scripting::DoesObjectExist(this->Base);
	}
	bool GameObject::Exists(GameObject^ obj)
	{ // STATIC!
		if (obj == nullptr) return false;
		if (obj->Handle == 0) return false;
		return obj->Exists();
	}
#pragma endregion base, handle, exists()

#pragma region Properties
	GTA::Vector3^ GameObject::Coordinates::get()
	{
		float x,y,z;
		pin_ptr<float> pX = &x;
		pin_ptr<float> pY = &y;
		pin_ptr<float> pZ = &z;
		Scripting::GetObjectCoordinates(Base,pX,pY,pZ);
		GTA::Vector3^ pos = gcnew GTA::Vector3(x,y,z);
		return pos;
	}
	void GameObject::Coordinates::set(GTA::Vector3^ pos)
	{
		Scripting::SetObjectCoordinates(Base,pos->X,pos->Y,pos->Z);
	}

	GTA::Quaternion^ GameObject::Quaternion::get()
	{
		float w,x,y,z;
		pin_ptr<float> pW = &w;
		pin_ptr<float> pX = &x;
		pin_ptr<float> pY = &y;
		pin_ptr<float> pZ = &z;
		Scripting::GetObjectQuaternion(Base,pW,pX,pY,pZ);
		GTA::Quaternion^ quat = gcnew GTA::Quaternion(w,x,y,z);
		return quat;
	}
	void GameObject::Quaternion::set(GTA::Quaternion^ pos)
	{
		Scripting::SetObjectQuaternion(Base,pos->W,pos->X,pos->Y,pos->Z);
	}

	f32 GameObject::Heading::get()
	{
		float heading;
		pin_ptr<float> pheading = &heading;
		Scripting::GetObjectHeading(Base,pheading);
		return heading;
	}
	void GameObject::Heading::set(f32 heading)
	{
		Scripting::SetObjectHeading(Base,heading);
	}

	f32 GameObject::Health::get()
	{
		f32 health;
		pin_ptr<f32> phealth = &health;
		Scripting::GetObjectHealth(Base,phealth);
		return health;
	}

	GTA::eModel GameObject::Model::get()
	{
		GTA::eModel model;
		pin_ptr<GTA::eModel> pmodel = &model;
		Scripting::GetObjectModel(Base,(Scripting::eModel*)pmodel);
		return model;
	}
#pragma endregion Coordinates, Quaternion, Heading, Health, Model

#pragma region Methods
//
#pragma endregion

};